﻿<%@ page language="java" import="java.util.*" pageEncoding="utf-8"%>
<%@ taglib uri="http://java.sun.com/jstl/core_rt" prefix="c"%>
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt"%>
<%
	String path = request.getContextPath();
	String basePath = request.getScheme() + "://" + request.getServerName() + ":" + request.getServerPort()
			+ path + "/";
%>
<c:set var="path" value="${pageContext.request.contextPath }" />
<!DOCTYPE HTML>
<html>
<head>
<meta charset="utf-8">
<META HTTP-EQUIV="Pragma" CONTENT="no-cache">
<meta name="renderer" content="webkit|ie-comp|ie-stand">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<meta name="viewport"
	content="width=device-width,initial-scale=1,minimum-scale=1.0,maximum-scale=1.0,user-scalable=no" />
<meta http-equiv="Cache-Control" content="no-siteapp" />
<LINK rel="Bookmark" href="../images/favicon.ico">
<!-- 本框架基本脚本和样式 -->
<script type="text/javascript"
	src="${path }/resource/js/jquery-2.1.4.min.js"></script>
<script type="text/javascript"
	src="${path }/resource/js/systools/echarts.js"></script>

<!-- 文件上传需要的样式 -->

<link rel="stylesheet" type="text/css"
	href="${path }/resource/plugin/kindeditor/themes/default/default.css" />
<link rel="stylesheet" type="text/css"
	href="${path }/resource/plugin/kindeditor/plugins/code/prettify.css" />
<script type="text/javascript"
	src="${path }/resource/plugin/kindeditor/kindeditor.js"></script>
<script type="text/javascript"
	src="${path }/resource/plugin/kindeditor/lang/zh_CN.js"></script>
<script type="text/javascript"
	src="${path }/resource/plugin/kindeditor/plugins/code/prettify.js"></script>

<title></title>
</head>

<form class="form form-horizontal" method="post" style="display: none;"
	enctype="multipart/form-data" target="blankFrame"
	action="${path }/resource/plugin/kindeditor/zking_upload_json.jsp?fileType=image&hiddenId=photo&flag=img_1">
	<input id="fileText" type="file" multiple name="file-1"
		onchange="fileChange()" /> <input type="submit" id="submitBtn" />
</form>
<input id="hiddenImg" style="display: none;">
<iframe src="" name="blankFrame" id="blankFrame"
	style="height: 100px; width: 100px; display: none;"> </iframe>

<div class="ibox-content">
	<div class="form-group control-label">
	<!-- 为ECharts准备一个具备大小（宽高）的Dom -->
	<div id="main" style="width: 1200px;height:600px;"></div>
	<div id="main1" style="width: 1200px;height:600px;"></div>
	</div>
</div>

<script type="text/javascript">
	
</script>
<script type="text/javascript"
	src="${path }/resource/js/systools/MBase.js"></script>
	<script type="text/javascript">
	var invokeUrl="${path}/admin/WorkLogAction/summaryGraph";
	/**
	 * 初始化功能列表
	 */
	  $(function() {// 初始化内容
		console.log(invokeUrl);	
		 function max(arr){
	        var j = arr[0]
	        for (var i=1;i<arr.length ;i++ ){
	            if(arr[i]>j){
	                j = arr[i];
	            }
	        }
	        return j;
	     }
		
		$.AjaxProxy().invoke(invokeUrl,
			function(loj) {
			var obj=loj[0].result.mapInfo;
			console.log(obj);
			var xData=[];
			var yData={};
			var i =1;
			var len = (Object.keys(obj)).length;
			var arr = [];
			var f =0;
			
			for(var i in obj){
				arr.push(obj[i].length)
				console.log(i);
				var item = obj[i];
					yData[f] =[];
					for(var k=0;k<item.length;k++){
						yData[f].push(item[k].price)
					}
				f++;
			}
			var xMaxLen = max(arr);
			for(var i in obj){
				if(obj[i].length==xMaxLen){
					var item = obj[i];
					for(var j=0;j<item.length;j++){
						xData.push(MTools.farmterTime(item[j].createTime))
					}
					break;
				}
				
			}
			console.log(xData)
			console.log(yData)
			
			var series =[];
			var name =[];
			var num = 0;
			var totalPrice = [];
			for(var ob in obj){
				
				var json={type:'line',stack: '总量'};
				console.log(ob);
				var item =obj[ob]
				json.name=item[0].projName;
				json.data=yData[num];
				name.push(item[0].projName);
				totalPrice.push(item[0].totalPrice);
				series.push(json);
				num++;
			}
			console.log(series);
			console.log(name);
			// 基于准备好的dom，初始化echarts实例
			  var myChart = echarts.init(document.getElementById('main'));
			  // 指定图表的配置项和数据
			  option = {
			  		title: {
			  	        text: '项目每日成本统计'
			  	    },
				  	tooltip: {
				          trigger: 'axis'
				    },
			  	    legend: {
			  	        data:name
			  	    },
				  	grid: {
			          left: '3%',
			          right: '4%',
			          bottom: '3%',
			          containLabel: true
				    },
			  	    xAxis:{
			  	        type: 'category',
			  	     	boundaryGap: false,
			  	        data: xData
			  	    },
			  	    yAxis:{
			  	        type: 'value'
			  	    },
			  	    series: series
			  	    
			  	};
			  // 使用刚指定的配置项和数据显示图表。
			  myChart.setOption(option);
		
		// 基于准备好的dom，初始化echarts实例
        var myChart1 = echarts.init(document.getElementById('main1'));

        // 指定图表的配置项和数据
        var option1 = {
            title: {
                text:'项目开发成本'
            },
            tooltip: {},
            legend: {
                data:['开发成本']
            },
            xAxis: {
                data: name
            },
            yAxis: {},
            series: [{
                name: '开发成本',
                type: 'bar',
                data: totalPrice
            }]
        };

        // 使用刚指定的配置项和数据显示图表
        myChart1.setOption(option1);
		
		});
	  });  
	
	</script>
<body>

</body>
</html>